package cn.kgc.pojo;

import cn.kgc.util.Constants;

import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;

//用户类
public class Users implements HttpSessionBindingListener{
    private int id;
    private String userName;
    private String password;
    private String email;
    private int userType;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getUserType() {
        return userType;
    }

    public void setUserType(int userType) {
        this.userType = userType;
    }

    //User对象放进session时（一个用户登录了），自动进入该方法
    public void valueBound(HttpSessionBindingEvent event) {
        Constants.USER_COUNT++;
    }

    //session失效（某个用户注销）、超时、手动的session中把某个属性移出
    public void valueUnbound(HttpSessionBindingEvent event) {
        Constants.USER_COUNT--;
    }
}
